Internet protocol suite |
---|
Application layer |
Transport layer |
Internet layer |
Link layer |
UDP-Lite is a connectionless protocol, very similar to UDP. Unlike UDP, where either all or none of a packet is protected by a checksum, UDP-Lite allows for partial checksums that only cover part of a datagram (header and the custom amount of the beginning of payload), and will therefore deliver packets that have been partially corrupted. It is designed for multimedia protocols, such as voice over IP, in which receiving a packet with a damaged payload is better than receiving no packet at all. For computing the checksum it uses the same checksum algorithm used for the UDP (and the TCP).
Since most modern link layers protect the carried data with a strong CRC and will discard damaged frames, making effective use of UDP-Lite requires the link layer to be aware of the network-layer data being carried. Since no current IP stacks implement such cross-layer interactions, making effective use of UDP-Lite currently requires specially modified device drivers.
The IP protocol identifier is 136, so UDP-Lite creates a new port space, differently from TCP and UDP, and UDP-Lite packets are not delivered to UDP applications (UDP has the protocol identifier 17).
Support for UDP-Lite was added in the Linux kernel version 2.6.20. The BSD socket API is extended to support UDP-Lite by the third parameter of the socket() system call: Set it to IPPROTO_UDPLITE
to request a UDP-Lite socket:
int s = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDPLITE);
One can also easily set what part of the packet will be covered by the checksum (starting from the beginning including header)
int val = 20; // 8 octets of header + 12 octets of some user protocol. setsockopt(s, SOL_UDPLITE, UDPLITE_SEND_CSCOV, &val, sizeof(int));
If a packet smaller than 12 octets is sent in such a setup, the checksum will cover the whole packet.
On the receiving side a socket will by default drop all packet which are not covered completely (UDP emulation). To permit for smaller coverage one can use:
int min = 20; // 8 octets of header + 12 octets of some user protocol. setsockopt(s, SOL_UDPLITE, UDPLITE_RECV_CSCOV, &min, sizeof(int));
This will allow for packets where at minimum 12 octets of user data are checksummed. Any packet with a smaller coverage will be silently dropped as bad. If a packet has a coverage length of at least 20 (including header) and its checksum is correct, it will be delivered to application (whole or part of the payload can still by corrupted, because it could be not covered by checksum or because the checksum was correct incidentally, but the latter is very unlikely). If the checksum is incorrect the packet will be dropped (because it is actually impossible to know if the error was inside the payload data or in the UDP-Lite header, so the packet could actually be destined for a different program).
The smallest possible coverage is 8 (headers need to be included in checksum). Packets with a smaller length of coverage will always be dropped independent of any settings (ignoring sniffers which are interested in all traffic) as not conforming to standard.